<template>
  <div>
    <h1>app axios</h1>
    <button @click="sendTwo">点击按钮发送两个get请求</button>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {

    };
  },
  mounted() {
    console.dir(axios);
    // get  查询学生的信息 http://localhost:8000/search_info_not
    // get  查询某个学生的成绩  http://localhost:8000/search_entry/01
    // let url = "http://localhost:8000/search_info_not";
    /*  axios
      .get(url)
      .then((res) => {
        console.log(res);
      })
      .catch((err) => {
        console.log(err);
      }); */
    /* let url = "http://localhost:8000/search_entry/01";
    axios
      .get(url)
      .then((res) => {
        console.log(res);
      })
      .catch((err) => {
        console.log(err);
      }); */
  },
  methods:{
    getStuInfo(){
      // 还没录数据      http://localhost:8000/search_info_not
      return axios.get("http://localhost:8000/search_entry/009");
    },
    getItemScore(){
      return axios.get("http://localhost:8000/search_entry/008");
    },
    sendTwo(){
      //并列发送多个ajax
      axios.all([this.getStuInfo(),this.getItemScore()]).then(axios.spread((info,score)=>{
        console.log(info,score);
        })
      )
    }
  }
}
</script>

<style lang="scss" scoped>

</style>